<?php

namespace App\BO\OrderStatus\State\Service;

use App\BO\OrderStatus\Events\OrderServiceFinishEvent;
use App\BO\OrderStatus\OrderStateContext;
use App\BO\OrderStatus\State\AOrderState;
use App\BO\OrderStatus\State\Report\ReportedState;
use App\BO\OrderStatus\State\WaitingCommentState;

/**
 * 服务中状态
 * Class ServicingState
 * @package App\BO\OrderStatus\State\Service
 */
class ServicingState extends AOrderState
{
    protected $desc = '服务中';

    /**
     * @inheritDoc
     */
    public function couldReport()
    {
        return true;
    }

    /**
     * @inheritDoc
     */
    public function serviceFinish()
    {
        $this->orderStateModifyStore->toWaitingComment();
        $this->stateContext->setOrderState(OrderStateContext::getInstance(WaitingCommentState::class));
        event(new OrderServiceFinishEvent($this->stateContext->getOrder()));
    }

    /**
     * @inheritDoc
     */
    public function report()
    {
        $this->orderStateModifyStore->toReported();
        $this->stateContext->setOrderState(OrderStateContext::getInstance(ReportedState::class));
    }
}
